#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll N = 2e5 + 10;

bool cmp(ll a,ll b)
{
    return a > b;
}
void solve()
{
    ll n;
    cin >> n;
    string s;
    cin >> s;
    string s1="CHICKEN";
    bool dz[7] = {false};
    ll now = 0;
    map<char, ll> mp;
    for (ll i = 0; i < s.size();i++)
    {
        mp[s[i]]++;
        if(now==0&&dz[now]==0&&s[i]=='C')
        {
            dz[now++] = true;
        }
        else if(now==1&&dz[now]==false&&s[i]=='H')
        {
            dz[now++] = true;
        }
        else if (now == 2 && dz[now] == false && s[i] == 'I')
        {
            dz[now++] = true;
        }
        else if (now == 3 && dz[now] == false && s[i] == 'C')
        {
            dz[now++] = true;
        }
        else if (now == 4 && dz[now] == false && s[i] == 'K')
        {
            dz[now++] = true;
        }
        else if (now == 5 && dz[now] == false && s[i] == 'E')
        {
            dz[now++] = true;
        }
        else if (now == 6 && dz[now] == false && s[i] == 'N')
        {
            dz[now++] = true;
        }
    }
    if(now!=7)
    {
        cout << "NO" << endl;
        return;
    }
    if((n-7)%2!=0)
    {
        cout << "NO" << endl;
        return;
    }
    mp['C']-=2;
    mp['H'] -= 1;
    mp['I'] -= 1;
    mp['K'] -= 1;
    mp['E'] -= 1;
    mp['N'] -= 1;
    vector<ll> a;
    now = 0;
    ll _a = n - 7;
    if(_a==0)
    {
        cout << "YES" << endl;
        return;
    }
    if (_a%2!= 0)
    {
        cout << "NO" << endl;
        return;
    }
    for (char i = 'A'; i <= 'Z';i++)
    {
        if(mp[i]!=0)
            a.push_back(mp[i]);
    }
    if(a.size()==0)
    {
        cout << "YES" << endl;
        return;
    }
    if(*max_element(a.begin(),a.end()) > _a/2 )
    {
        cout << "NO" << endl;
    }
    else 
    {
        cout << "YES" << endl;
    }
   
}
int main()
{
    ll t = 1;
    cin >> t;
    while (t--)
    {
        solve();
    }
    return 0;
}